<?php
if (!isset($_POST['id']) || !isset($_POST['password'])) {
	exit();
}
 
require_once ('../conf/pdoConnect.php');
require_once ('./check.php');

$id = intval($_POST['id']);
if ($id == $_SESSION['uid']) {
	$password = md5($_POST['password']);
	changeUserInfo($db, $id, $password);
}

$db = null;

function changeUserInfo($db, $id, $psw)
{	
	$sql = "update user set `password` = ? where `id` = ?";
	$stmt = $db->prepare($sql);
	$exec = $stmt->execute(array($psw, $id));

	if ($exec) {
		echo "修改成功";
	}
}
